package com.rfsp.mcp.mapper;

import java.util.List;

import com.rfsp.mcp.pojo.sdto.PfmSDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.rfsp.common.base.BaseMapper;
import com.rfsp.mcp.pojo.po.PfmPO;
import com.rfsp.mcp.pojo.vo.PfmVO;
import org.springframework.stereotype.Repository;

@Repository
public interface PfmMapper extends BaseMapper<PfmPO> {

	@Select("SELECT * FROM MCP_PFM WHERE AREA_CODE = #{areaCode}")
	PfmVO getByAreaCode(@Param("areaCode") String areaCode);

	@Select("select P.*,PL.PAY_LOG_CODE from MCP_PFM P inner join mcp_mi_pay_log PL on PL.pfm_id = P.id where PL.ID = #{payLogId}")
    PfmVO getByPayLogId(@Param("payLogId") Long payLogId);

	@Select("SELECT AREA_CODE FROM MCP_PFM ORDER BY AREA_CODE")
	List<String> queryAreaCode();

	@Select("SELECT * FROM MCP_PFM ORDER BY AREA_CODE")
	List<PfmVO> query(@Param("sdto") PfmSDTO stdo);

	/**
	@Select("SELECT * FROM MCP_PFM where id in (select pfm_id from MCP_ORG_YBJ where ORG_ID=#{orgid}) ORDER BY id")
	List<PfmVO> queryByOrgId(@Param("orgid") Long orgid);
	 **/

	@Select("select t.id, t.pfm_name, t.area_code, t.operator_name, t.online_date, oy.id as ybj_id, oy.aid as ybj_aid, oy.org_no" +
			" from mcp_pfm t inner join mcp_org_ybj oy on oy.pfm_id=t.id where t.STATUS='1' and oy.org_id=#{orgid}")
	List<PfmVO> queryByOrgId(@Param("orgid") Long orgid);

}